//
//  ZHUCEViewController.m
//  JING01
//
//  Created by 楠木凉生本青春 on 2018/3/18.
//  Copyright © 2018年 楠木凉生本青春. All rights reserved.
//

#import "ZHUCEViewController.h"
#import "DENGRUViewController.h"
#import "mainView.h"
#import "leftNav.h"
#import "YSHYSlideViewController.h"
#import "XHToast.h"
#import "Header.h"
#import <BmobSDK/Bmob.h>


@interface ZHUCEViewController ()
@property (weak, nonatomic) IBOutlet UIButton *zhuce;
@property (weak, nonatomic) IBOutlet UITextField *user;
@property (weak, nonatomic) IBOutlet UITextField *email;
@property (weak, nonatomic) IBOutlet UITextField *password01;
@property (weak, nonatomic) IBOutlet UITextField *password02;
@property (weak, nonatomic) IBOutlet UIButton *btn;

@end

@implementation ZHUCEViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationController setNavigationBarHidden:YES animated:YES];

    _zhuce.layer.masksToBounds=YES;
    _zhuce.layer.cornerRadius=_zhuce.bounds.size.height/2;

    [_zhuce addTarget:self  action:@selector(jump) forControlEvents:UIControlEventTouchDown];
    
    
    _user.layer.masksToBounds=YES;
    _user.layer.cornerRadius=_user.bounds.size.height/2;
    _email.layer.masksToBounds=YES;
    _email.layer.cornerRadius=_email.bounds.size.height/2;
    _password01.layer.masksToBounds=YES;
    _password01.layer.cornerRadius=_password01.bounds.size.height/2;
    _password02.layer.masksToBounds=YES;
    _password02.layer.cornerRadius=_password02.bounds.size.height/2;
    [_user setValue:[UIFont systemFontOfSize:20] forKeyPath:@"_placeholderLabel.font"];
    [_email setValue:[UIFont systemFontOfSize:20] forKeyPath:@"_placeholderLabel.font"];
    [_password01 setValue:[UIFont systemFontOfSize:20] forKeyPath:@"_placeholderLabel.font"];
    [_password02 setValue:[UIFont systemFontOfSize:20] forKeyPath:@"_placeholderLabel.font"];
   
}
- (IBAction)ttt:(id)sender {
    DENGRUViewController *JM=[[DENGRUViewController alloc]init];
    [self.navigationController pushViewController:JM animated:YES];
}
-(void)addUser{
    NSString *schoolName = self.user.text;
    NSString *emailValue = self.email.text;
    NSString *passworValue = self.password02.text;
    NSString *schoolValue = self.password01.text;
    NSDictionary *parameters = @{@"password":passworValue,@"email":emailValue,@"school_num":schoolValue,@"school":schoolName};
   // [HttpReq AFPostDataRegister:parameters];
    AFHTTPSessionManager* session=[AFHTTPSessionManager manager];
    session.responseSerializer=[AFHTTPResponseSerializer serializer];
    
    [session POST:HTTPREGISTER parameters:parameters progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"成功");
        NSString *str = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSLog(@"%@",str);
        [XHToast showCenterWithText:@"注册成功"];
        DENGRUViewController *JM = [[DENGRUViewController alloc] init];
        [self.navigationController pushViewController:JM animated:YES];
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"失败");
        
    }];
}


-(void)jump{
    [self addUser];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.user resignFirstResponder];
    [self.email resignFirstResponder];
    [_password01 resignFirstResponder];
    [_password02 resignFirstResponder];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
